import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n = in.nextInt();
        while (n -- != 0){
            char[] s = in.next().toCharArray();
            int q = s.length;
            for (int i = q - 1; i >= 0 ; i--) {
                if((s[i] - '0') % 2 == 0){
                    swap(s,i,q - 1);
                    break;
                }
            }
            if((s[q-1] - '0') % 2 == 0){
                System.out.println(s);
            }else {
                System.out.println(-1);
            }
        }
    }
    private static void swap(char[] s,int i,int n){
        char tmp = s[i];
        s[i] = s[n];
        s[n] = tmp;
    }
}